/*
 * Copyright 2018-10-6 18:56:37 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.erp.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.erp.core.EmployeeManager;
import com.lap.scp.erp.dal.EmployeeDAO;
import com.lap.scp.erp.domain.EmployeeDO;
import com.lap.scp.erp.query.EmployeeQueryVO;

/**
 * <pre>
 * 员工信息，记录员工基本信息，主要是计算统计金额使用，暂时没有什么特别需要业务代码默认实现类，这里提供最小元素原子操作，所以尽量少在该类中做流程代码。
 * 业务流程代码应该写在AO中。
 * </pre>
 * 
 * @author 劳水生 Exp
 * @Date 2018-10-6 18:56:37
 * @since 2.0.0
 */
@Service("employeeManager")
public class DefaultEmployeeManager implements EmployeeManager {
	/**
	 * 员工信息，记录员工基本信息，主要是计算统计金额使用，暂时没有什么特别需要数据操作对象
	 */
	@Resource
	private EmployeeDAO employeeDAO;

	@Override
	public void insertEmployee(EmployeeDO employeeDO) throws ManagerException {
		employeeDAO.insertEmployee(employeeDO);
	}

	@Override
	public int deleteById(Integer employeeId) throws ManagerException {
		return employeeDAO.deleteById(employeeId);
	}

	@Override
	public EmployeeDO queryById(Integer employeeId) throws ManagerException {
		return employeeDAO.queryById(employeeId);
	}

	@Override
	public EmployeeDO queryByName(String fullName) throws ManagerException {
		return employeeDAO.queryByName(fullName);
	}

	@Override
	public List<EmployeeDO> queryList() throws ManagerException {
		return employeeDAO.queryList();
	}

	@Override
	public List<EmployeeDO> queryPage(Page page, EmployeeQueryVO queryVO) throws ManagerException {
		int count = employeeDAO.countPage(queryVO);
		if (count == 0) {
			return Collections.emptyList();
		} else {
			page.setTotalItem(count);
			return employeeDAO.queryPage(page, queryVO);
		}
	}

	@Override
	public int updateEmployee(EmployeeDO employeeDO) throws ManagerException {
		return employeeDAO.updateEmployee(employeeDO);
	}

}
